Despite the high prevalence of epilepsy, which affects nearly 4% of the population over their lifetime, roughly one third of afflicted patients are incompletely responsive to anticonvulsant drugs, requiring in severe cases neurosurgical resections or novel approaches such as deep-brain stimulation (DBS). Recently, I helped develop an electrophysiology-based online DBS protocol for seizure detection and interruption in rodent models of absence epilepsy, a form of epilepsy involving aberrant thalamocortical activity. However, like other online DBS procedures which detect seizures as they occur, there was little ability to predict incipient seizures due in large part to limited spatiotemporal resolution of the signal we used, the electrocorticogram (ECoG). ECoG and related electroencephalogram (EEG), being large scale local field potential approaches, do not provide single-cell resolution of neural dynamics that are likely required to obtain predictive information. Over the last decade, the field of brain-machine interface (BMI) has made breakthroughs in neuroscience and engineering by developing methods for multi-electrode array recording of large scale neural spiking activity and efficient reduction of the resultant high-dimensional neural activity to a smaller number of dimensions to effectively control neural prostheses. We predict that this approach will be invaluable for understanding neural dynamics during seizures and stimulation, and for developing predictive algorithms and adaptive DBS protocols. Therefore, the goal of this project is to precisely characterize thalamocortical neural activity during spontaneous absence seizures and following thalamic stimulation by combining large-scale thalamic and cortical neural recordings, optogenetics, and BMI mathematical techniques. Additionally, the experiments presented in this proposal will use the recorded neural activity to develop adaptive algorithms that both predict oncoming seizure activity and modify stimulation parameters based on the neural state and response to stimulation in real-time. This proposal is aimed towards increasing our understanding of the neural dynamics of epileptic networks and improving the efficacy and safety of online DBS.